package com.luyu.customvalid;

import jakarta.validation.Constraint;
import jakarta.validation.OverridesAttribute;
import jakarta.validation.Payload;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import org.hibernate.validator.constraints.CompositionType;
import org.hibernate.validator.constraints.ConstraintComposition;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @Author lyh
 */

@Email
@NotNull
@ConstraintComposition(CompositionType.OR)
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {})
public @interface CustomEmailCCAnno {
    @OverridesAttribute(constraint = Email.class, name = "regexp")
    String regexp();

    @OverridesAttribute.List({
            @OverridesAttribute(constraint = Email.class, name = "message"),
            @OverridesAttribute(constraint = NotNull.class, name = "message")
    }
    )
    String message() default "{email.notnull}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
